/* $Header: pi_meth.c,v 2.2 01/10/02 10:27:59 przybyls Exp $ */

/**begin_proto**/
/* $Header: pi_meth.c,v 2.2 01/10/02 10:27:59 przybyls Exp $ */
/**end_proto**/

/***********************************************************************/
/*                                                                     */
/*                  Copyright Hewlett-Packard Co. 1991                 */
/*                                                                     */
/***********************************************************************/

/***********************************************************************/
/* MODULE NAME:                                                        */
/* ============                                                        */
/*                                                                     */
/* Author:                                                             */
/*                                                                     */
/* MODULE PURPOSE:                                                     */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/***********************************************************************/


/*****************************/
/*   GLOBAL INCLUDE FILES    */
/*****************************/

#include <typedefs.h>
#include <pcb_defs.h>
#include <p_wkfile.h>
#include <wkfile.h>
#include <p_status.h>
#include <error.h>
#include <list_mgmt.h>
#include <ramps.h>
#include <zone_config.h>
#include <zone_status.h>
#include <status.h>
#include <meth_config.h>
#include <exception.h>
#include <err_handler.h>
#include <zone_ui.h>
#include <keyboard.h>
#include <p_ui.h>

#include <method.h>
#include <mio.h>
#include <cmd_set.h>
#include <hostutil.h>



/*****************************/
/*   LOCAL INCLUDE FILES     */
/*****************************/

#include "proto.h"
#include "pneu_int.h"

/*****************************/
/*   GLOBAL VARIABLES        */
/*****************************/


/*****************************/
/*   EXTERNAL VARIABLES      */
/*****************************/


/*****************************/
/*   LOCAL DEFINES           */
/*****************************/

#define pFINLT (void *)&Inst_Status.Pneu.Frnt_Inlet
#define pBINLT (void *)&Inst_Status.Pneu.Back_Inlet

#define pCOL1  (void *)&Inst_Status.Pneu.Column_1
#define pCOL2  (void *)&Inst_Status.Pneu.Column_2

#define pFDET  ((void *)&Inst_Status.Pneu.Frnt_Detector)
#define pBDET  ((void *)&Inst_Status.Pneu.Back_Detector)

#define pAUX   (void *)&Inst_Status.Pneu.Aux
#define pA3    (void *)&Inst_Status.Pneu.Aux.Aux_3
#define pA4    (void *)&Inst_Status.Pneu.Aux.Aux_4
#define pA5    (void *)&Inst_Status.Pneu.Aux.Aux_5



/*****************************/
/*   STATIC VARIABLES        */
/*****************************/


/*****************************/
/*   IMPLEMENT SECTION       */
/*****************************/

/**begin_proto**/

void MethodStatusStructUpdate( void )

/**end_proto**/
{

     UpdateShadowedSetpts( );

}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/

void LoadDefaultSSSetpts( pINLET_STATUS  status )

{

        pINLET_CONFIG config;
        pINLET_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_Type         = He;
        config->Pres_Equib_Time  = 6000;
        config->Flow_Equib_Time  = 6000;

        wkfile->On_Off           = OFF;
        wkfile->Injection_Mode = SPLIT;
        wkfile->Inlet_Pressure   = (689476/status->Dcm2_Per_IU); /* 10 psi */
        wkfile->Total_Inlet_Flow = 25 * status->IU_Scaling;
        wkfile->Purge_Flow       = 15 * status->IU_Scaling;
        wkfile->Purge_Time       = TimeToMilliSecs( 75 ); /* 45 secs */
        wkfile->Pressure_Pulse_Pressure = (689476/status->Dcm2_Per_IU); /* 10 psi */
        wkfile->Pulse_Time       = TimeToMilliSecs( 75 ); /* 45 secs */
        wkfile->Split_Ratio      = 100 * SPLIT_RATIO_INTERNAL_SCALE;
        wkfile->Miser_Mode       = OFF;
        wkfile->Miser_Flow       = 20 * status->IU_Scaling;
        wkfile->Miser_Time       = TimeToMilliSecs( 200 ); /*  2 minutes */
        wkfile->Flow_Equib_Time  = TimeToMilliSecs( 10 );  /*  6 seconds */
        wkfile->Pres_Equib_Time  = TimeToMilliSecs( 10 );  /*  6 seconds */

}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/

void LoadDefaultGptvSetpts( pINLET_STATUS  status )

{

        pINLET_CONFIG config;
        pINLET_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_Type         = He;
        config->Pres_Equib_Time  = 6000;
        config->Flow_Equib_Time  = 6000;

        wkfile->On_Off           = OFF;
        wkfile->Injection_Mode   = SOLVENT_VENT;
        wkfile->Inlet_Pressure   = (689476/status->Dcm2_Per_IU); /* 10 psi */
        wkfile->Total_Inlet_Flow = 25 * status->IU_Scaling;
        wkfile->Purge_Flow       = 15 * status->IU_Scaling;
        wkfile->Purge_Time       = TimeToMilliSecs( 35 ); /* 20 secs */
        wkfile->Vent_Pressure    = (689476/(2*status->Dcm2_Per_IU)); /*  5 psi */
        wkfile->Vent_Flow        = 100 * status->IU_Scaling;
        wkfile->Vent_Time        = TimeToMilliSecs( 25 );  /* 15 seconds */
        wkfile->Pressure_Pulse_Pressure = (689476/status->Dcm2_Per_IU); /* 10 psi */
        wkfile->Pulse_Time       = TimeToMilliSecs( 75 ); /* 45 secs */
        wkfile->Split_Ratio      = 100 * SPLIT_RATIO_INTERNAL_SCALE;
        wkfile->Miser_Mode       = OFF;
        wkfile->Miser_Flow       = 20 * status->IU_Scaling;
        wkfile->Miser_Time       = TimeToMilliSecs( 200 ); /*  2 minutes */
        wkfile->Flow_Equib_Time  = TimeToMilliSecs( 10 );  /*  6 seconds */
        wkfile->Pres_Equib_Time  = TimeToMilliSecs( 10 );  /*  6 seconds */

}


void LoadDefaultCOCSetpts( pINLET_STATUS  status )

{

        pINLET_CONFIG config;
        pINLET_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_Type         = He;
        config->Pres_Equib_Time  = 6000;
        config->Flow_Equib_Time  = 6000;  /* initialized, even though not used */

        wkfile->On_Off           = OFF;
        wkfile->Injection_Mode   = SPLITLESS;
        wkfile->Inlet_Pressure   = (689476/status->Dcm2_Per_IU); /* 10 psi */
        wkfile->Total_Inlet_Flow = 0;
        wkfile->Purge_Flow       = 15 * status->IU_Scaling;
        wkfile->Pressure_Pulse_Pressure = 0;
        wkfile->Pulse_Time       = 0;
        wkfile->Split_Ratio      = 0;
        wkfile->Purge_Time       = 0;
        wkfile->Miser_Mode       = OFF;
        wkfile->Miser_Flow       = 0;
        wkfile->Miser_Time       = 0;
        wkfile->Flow_Equib_Time  = TimeToMilliSecs( 10 );  /*  6 seconds */
        wkfile->Pres_Equib_Time  = TimeToMilliSecs( 10 );  /*  6 seconds */

}


void LoadDefaultPPSetpts( pINLET_STATUS  status )

{

        pINLET_CONFIG config;
        pINLET_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_Type         = He;
        config->Pres_Equib_Time  = 6000;
        config->Flow_Equib_Time  = 6000;

        wkfile->On_Off           = OFF;
        wkfile->Injection_Mode   = SPLITLESS;
        wkfile->Inlet_Pressure   = (689476/status->Dcm2_Per_IU); /* 10 psi */
        wkfile->Total_Inlet_Flow = 3 * status->IU_Scaling;
        wkfile->Pressure_Pulse_Pressure = 0;
        wkfile->Pulse_Time       = 0;
        wkfile->Split_Ratio      = 0;
        wkfile->Miser_Mode       = OFF;
        wkfile->Miser_Flow       = 0;
        wkfile->Miser_Time       = 0;
        wkfile->Flow_Equib_Time  = TimeToMilliSecs( 10 );  /*  6 seconds */
        wkfile->Pres_Equib_Time  = TimeToMilliSecs( 10 );  /*  6 seconds */
}


void LoadDefaultVISetpts( pINLET_STATUS  status )

{
        pINLET_CONFIG config;
        pINLET_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        LoadDefaultSSSetpts( status );              /* just to get inits if user chgs vent def'n . */
                                                    /* includes setting Inj_Mode to SPLIT          */

/*      config->VI_Split_Port  = PLUMBED;  MOVED TO "SetDefaultVentConfig"                        */

        wkfile->VI_Inj_Mode_Save = SPLIT;           /* to init if CAPPED -> PLUMBED happens later ... */
        wkfile->VI_Inj_Time_Save = TimeToMilliSecs( 225 );    /* 2.25 min */
        wkfile->Split_Ratio      = 20 * SPLIT_RATIO_INTERNAL_SCALE;
        wkfile->Purge_Time       = TimeToMilliSecs( 250 ); /* 2.50 min */
        wkfile->Miser_Time       = TimeToMilliSecs( 375 ); /*  3.75 minutes */

        if (config->VI_Split_Port== PLUMBED)
        {
           wkfile->Injection_Mode = SPLIT;             /* just to be sure ...                         */
           wkfile->VI_Inj_Time = 0 ;
        }
        else
        {
           wkfile->Injection_Mode = DIRECT ;           /* just to be sure ...                         */
           wkfile->VI_Inj_Time = TimeToMilliSecs( 225 );    /* 2.25 min */
        };
}

void LoadDefaultACISetpts( pINLET_STATUS  status )

{

        pINLET_CONFIG config;
        pINLET_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_Type         = He;
        config->Pres_Equib_Time  = 6000;
        config->Flow_Equib_Time  = 6000;

        wkfile->On_Off           = OFF;
        wkfile->Injection_Mode   = SPLITLESS;
        wkfile->Inlet_Pressure   = (689476/status->Dcm2_Per_IU); /* 10 psi */
        wkfile->Total_Inlet_Flow = 3 * status->IU_Scaling;
        wkfile->Pressure_Pulse_Pressure = 0;
        wkfile->Pulse_Time       = 0;
        wkfile->Split_Ratio      = 0;
        wkfile->Miser_Mode       = OFF;
        wkfile->Miser_Flow       = 0;
        wkfile->Miser_Time       = 0;
        wkfile->Flow_Equib_Time  = TimeToMilliSecs( 10 );  /*  6 seconds */
        wkfile->Pres_Equib_Time  = TimeToMilliSecs( 10 );  /*  6 seconds */
}


void LoadDefaultManInletSetpts( pINLET_STATUS  status )

{

        pINLET_CONFIG config;
        pINLET_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;


        config->Gas_Type        = He;
        config->P_Sensor_Range  = INVALID_PS_RANGE;
        config->Pres_Equib_Time = 6000;
        config->Flow_Equib_Time = 6000;

        wkfile->Injection_Mode   = SPLIT;
        wkfile->Purge_Time       = 0;
        wkfile->On_Off           = ON;

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/

void LoadDefaultFIDSetpts ( pDETECTOR_STATUS status )

{

        pDETECTOR_CONFIG config;
        pDETECTOR_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_1.Gas_Type = H2;
        config->Gas_2.Gas_Type = Air;
        config->Gas_3.Gas_Type = N2;

        wkfile->Gas_1.On_Off         = OFF;
        status->Gas_1.Desired_Flow   = wkfile->Gas_1.Desired_Flow   = 40 * status->Gas_1.IU_Scaling;

        wkfile->Gas_2.On_Off         = OFF;
        status->Gas_2.Desired_Flow   = wkfile->Gas_2.Desired_Flow   = 450 * status->Gas_2.IU_Scaling;

        wkfile->Gas_3.On_Off         = OFF;
        status->Gas_3.Desired_Flow   = wkfile->Gas_3.Desired_Flow   = 50 * status->Gas_3.IU_Scaling;

        wkfile->Constant_Total_Makeup = OFF;
        wkfile->Desired_Total_Makeup_Flow = 50 * status->Gas_3.IU_Scaling;
}

void LoadDefaultAuxDetSetpts ( pDETECTOR_STATUS status )

{

        pDETECTOR_CONFIG config;
        pDETECTOR_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        /* status->Wkfile->Pres_Equib_Time       = TimeToMilliSecs( 10 );  /! 6 seconds !/   ?? revisit ?? */

        config->Gas_1.Gas_Type = He;
        config->Gas_2.Gas_Type = He;
        config->Gas_3.Gas_Type = He;

        wkfile->Gas_1.On_Off         = OFF;
        status->Gas_1.Desired_Flow   = wkfile->Gas_1.Desired_Flow =  0 ;
        status->Gas_1.Desired_Pres   = wkfile->Gas_1.Desired_Pres =  0 ;


        wkfile->Gas_2.On_Off         = OFF;
        status->Gas_2.Desired_Flow   = wkfile->Gas_2.Desired_Flow =  0 ;
        status->Gas_2.Desired_Pres   = wkfile->Gas_2.Desired_Pres =  0 ;

        wkfile->Gas_3.On_Off         = OFF;
        status->Gas_3.Desired_Flow   = wkfile->Gas_3.Desired_Flow =  0 ;
        status->Gas_3.Desired_Pres   = wkfile->Gas_3.Desired_Pres =  0 ;

}


void LoadDefaultTCDSetpts ( pDETECTOR_STATUS status )

{

        pDETECTOR_CONFIG config;
        pDETECTOR_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_1.Gas_Type = UNKNOWN_GAS;
        config->Gas_2.Gas_Type = He;
        config->Gas_3.Gas_Type = He;


        wkfile->Gas_1.On_Off         = OFF;
        status->Gas_1.Desired_Flow   = wkfile->Gas_1.Desired_Flow   = 0;

        wkfile->Gas_2.On_Off         = OFF;
        status->Gas_2.Desired_Flow   = wkfile->Gas_2.Desired_Flow   = 10 * status->Gas_2.IU_Scaling;

        wkfile->Gas_3.On_Off         = OFF;
        status->Gas_3.Desired_Flow   = wkfile->Gas_3.Desired_Flow   = 5 * status->Gas_3.IU_Scaling;

        wkfile->Constant_Total_Makeup = ON;
        wkfile->Desired_Total_Makeup_Flow = 5 * status->Gas_3.IU_Scaling;
}


void LoadDefaultECDSetpts ( pDETECTOR_STATUS status )

{

        pDETECTOR_CONFIG config;
        pDETECTOR_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_1.Gas_Type = UNKNOWN_GAS;
        config->Gas_2.Gas_Type = N2;
        config->Gas_3.Gas_Type = N2;


        wkfile->Gas_1.On_Off         = OFF;
        status->Gas_1.Desired_Flow   = wkfile->Gas_1.Desired_Flow   = 0;

        wkfile->Gas_2.On_Off         = OFF;
        status->Gas_2.Desired_Flow   = wkfile->Gas_2.Desired_Flow   = 6 * status->Gas_2.IU_Scaling;

        wkfile->Gas_3.On_Off         = OFF;
        status->Gas_3.Desired_Flow   = wkfile->Gas_3.Desired_Flow   = 60 * status->Gas_3.IU_Scaling;

        wkfile->Constant_Total_Makeup = OFF;
        wkfile->Desired_Total_Makeup_Flow = 60 * status->Gas_3.IU_Scaling;
}

void LoadDefaultUECDSetpts ( pDETECTOR_STATUS status )

{

        pDETECTOR_CONFIG config;
        pDETECTOR_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_1.Gas_Type = UNKNOWN_GAS;
        config->Gas_2.Gas_Type = UNKNOWN_GAS;
        config->Gas_3.Gas_Type = N2;


        wkfile->Gas_1.On_Off         = OFF;
        status->Gas_1.Desired_Flow   = wkfile->Gas_1.Desired_Flow   = 0;

        wkfile->Gas_2.On_Off         = OFF;
        status->Gas_2.Desired_Flow   = wkfile->Gas_2.Desired_Flow   = 0;

        wkfile->Gas_3.On_Off         = OFF;
        status->Gas_3.Desired_Flow   = wkfile->Gas_3.Desired_Flow   = 60 * status->Gas_3.IU_Scaling;

        wkfile->Constant_Total_Makeup = OFF;
        wkfile->Desired_Total_Makeup_Flow = 60 * status->Gas_3.IU_Scaling;
}

void LoadDefaultLDIDSetpts ( pDETECTOR_STATUS status )

{

        pDETECTOR_CONFIG config;
        pDETECTOR_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_1.Gas_Type = UNKNOWN_GAS;
        config->Gas_2.Gas_Type = UNKNOWN_GAS;
        config->Gas_3.Gas_Type = He;


        wkfile->Gas_1.On_Off         = OFF;
        status->Gas_1.Desired_Flow   = wkfile->Gas_1.Desired_Flow   = 0;

        wkfile->Gas_2.On_Off         = OFF;
        status->Gas_2.Desired_Flow   = wkfile->Gas_2.Desired_Flow   = 0;

        wkfile->Gas_3.On_Off         = OFF;
        status->Gas_3.Desired_Flow   = wkfile->Gas_3.Desired_Flow   = 30 * status->Gas_3.IU_Scaling;

        wkfile->Constant_Total_Makeup = OFF;
        wkfile->Desired_Total_Makeup_Flow = 30 * status->Gas_3.IU_Scaling;
}



void LoadDefaultNPDSetpts ( pDETECTOR_STATUS status )

{

        pDETECTOR_CONFIG config;
        pDETECTOR_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_1.Gas_Type = H2;
        config->Gas_2.Gas_Type = Air;
        config->Gas_3.Gas_Type = He;


        wkfile->Gas_1.On_Off         = OFF;
        status->Gas_1.Desired_Flow   = wkfile->Gas_1.Desired_Flow   = 2 * status->Gas_1.IU_Scaling;

        wkfile->Gas_2.On_Off         = OFF;
        status->Gas_2.Desired_Flow   = wkfile->Gas_2.Desired_Flow   = 60 * status->Gas_2.IU_Scaling;

        wkfile->Gas_3.On_Off         = OFF;
        status->Gas_3.Desired_Flow   = wkfile->Gas_3.Desired_Flow   = 30 * status->Gas_3.IU_Scaling;

        wkfile->Constant_Total_Makeup = OFF;
        wkfile->Desired_Total_Makeup_Flow = 30 * status->Gas_3.IU_Scaling;
}


void LoadDefaultFPDSetpts ( pDETECTOR_STATUS status )

{
        pDETECTOR_CONFIG config;
        pDETECTOR_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_1.Gas_Type = H2;
        config->Gas_2.Gas_Type = Air;
        config->Gas_3.Gas_Type = N2;


        wkfile->Gas_1.On_Off         = OFF;
        status->Gas_1.Desired_Flow   = wkfile->Gas_1.Desired_Flow   = 75 * status->Gas_1.IU_Scaling;

        wkfile->Gas_2.On_Off         = OFF;
        status->Gas_2.Desired_Flow   = wkfile->Gas_2.Desired_Flow   = 100 * status->Gas_2.IU_Scaling;

        wkfile->Gas_3.On_Off         = OFF;
        status->Gas_3.Desired_Flow   = wkfile->Gas_3.Desired_Flow   = 60 * status->Gas_3.IU_Scaling;

        wkfile->Constant_Total_Makeup = OFF;
        wkfile->Desired_Total_Makeup_Flow = 60 * status->Gas_3.IU_Scaling;

}


void LoadDefaultManDetSetpts ( pDETECTOR_STATUS status )

{

        pDETECTOR_CONFIG config;
        pDETECTOR_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        switch ( config->Type )
        {
           case MAN_FID:
                          wkfile->Gas_1.On_Off         = OFF;
                          wkfile->Gas_2.On_Off         = OFF;
                          wkfile->Gas_3.On_Off         = OFF;
                          config->Gas_1.Gas_Type       = H2;
                          config->Gas_2.Gas_Type       = Air;
                          config->Gas_3.Gas_Type       = N2;
                          break;
           case MAN_FPD:
                          wkfile->Gas_1.On_Off         = OFF;
                          wkfile->Gas_2.On_Off         = OFF;
                          wkfile->Gas_3.On_Off         = OFF;
                          config->Gas_1.Gas_Type       = H2;
                          config->Gas_2.Gas_Type       = Air;
                          config->Gas_3.Gas_Type       = N2;
                          break;
           case MAN_NPD:
                          wkfile->Gas_1.On_Off         = OFF;
                          wkfile->Gas_2.On_Off         = OFF;
                          wkfile->Gas_3.On_Off         = OFF;
                          config->Gas_1.Gas_Type       = H2;
                          config->Gas_2.Gas_Type       = Air;
                          config->Gas_3.Gas_Type       = N2;
                          break;
           case MAN_ECD:
                          wkfile->Gas_1.On_Off         = OFF;
                          wkfile->Gas_2.On_Off         = OFF;
                          wkfile->Gas_3.On_Off         = OFF;
                          config->Gas_1.Gas_Type       = UNKNOWN_GAS;
                          config->Gas_2.Gas_Type       = N2;
                          config->Gas_3.Gas_Type       = N2;
                          break;
           case MAN_TCD:
                          wkfile->Gas_1.On_Off         = OFF;
                          wkfile->Gas_2.On_Off         = OFF;
                          wkfile->Gas_3.On_Off         = OFF;
                          config->Gas_1.Gas_Type       = UNKNOWN_GAS;
                          config->Gas_2.Gas_Type       = He;
                          config->Gas_3.Gas_Type       = He;
                          break;
           default:
                          wkfile->Gas_1.On_Off         = OFF;
                          wkfile->Gas_2.On_Off         = OFF;
                          wkfile->Gas_3.On_Off         = OFF;
                          config->Gas_1.Gas_Type       = UNKNOWN_GAS;
                          config->Gas_2.Gas_Type       = UNKNOWN_GAS;
                          config->Gas_3.Gas_Type       = UNKNOWN_GAS;
        }

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void LoadDefaultInletSetpts(pINLET_STATUS  status )

/**end_proto**/
{

/* REVISIT !! Replace next 5 lines with calls to a "zeroing fn" for InletConfig and InletWkfile structures !!! */
    status->Wkfile->VI_Inj_Time = 0 ;
/*  status->Config->VI_Split_Port    = CAPPED-1 ; !! set to zero !!  See SetDefaultVentConfig in startup.c    */
    if ( status->Config->Type != VOLATILES ) SetDefaultVentConfig( status );
    status->Wkfile->Vent_Pressure    =  0;
    status->Wkfile->Vent_Flow        =  0;
    status->Wkfile->Vent_Time        =  0;

    switch ( status->Config->Type )
    {
         case SS:
         case PTV: LoadDefaultSSSetpts( status );
                   break;
         case COC: LoadDefaultCOCSetpts ( status );
                   break;
         case PP:  LoadDefaultPPSetpts ( status );
                   break;
         case ACI: LoadDefaultACISetpts ( status );
                   break;
         case SIMDIST:
                   LoadDefaultACISetpts ( status );
                   break;
         case VOLATILES:
                   LoadDefaultVISetpts ( status );
                   break;
         case CIS3:
         case CIS4: LoadDefaultGptvSetpts ( status );
                   break;
         default:  LoadDefaultManInletSetpts ( status );
    }

}

/**begin_proto**/

void LoadDefaultColumnSetpts( pCOLUMN_STATUS  status )

/**end_proto**/
{

       status->Config->Length                     = 3000;       /*  30 m */
       status->Config->Diam                       = 320;        /* 320 u */
       status->Config->Film_Thickness             = 0;
       status->Config->Vacuum_Comp                = OFF;
       status->Config->Outlet_Pressure_Correction = OFF;
       status->Config->Outlet_Correction          = 0;

       status->Wkfile->Control_Mode               = CONST_PRES;

       if ( status->Position == 1 )
       {
          if ( Inst_Config.Pneu.Frnt_Inlet.Type != NO_INLET ) status->Config->Source         =  FRNT_INLET;
          else                                                status->Config->Source         =  UNKNOWN_SOURCE;

          if ( EpcDetector( &Inst_Status.Pneu.Frnt_Detector ) ||
               ManDetector( &Inst_Status.Pneu.Frnt_Detector )) status->Config->Outlet         = FRNT_DET;
          else                                                 status->Config->Outlet         = UNKNOWN_OUTLET;
       }
       else
       {
          if ( Inst_Config.Pneu.Back_Inlet.Type != NO_INLET ) status->Config->Source         =  BACK_INLET;
          else                                                status->Config->Source         =  UNKNOWN_SOURCE;

          if ( EpcDetector( &Inst_Status.Pneu.Back_Detector ) ||
               ManDetector( &Inst_Status.Pneu.Back_Detector )) status->Config->Outlet         = BACK_DET;
          else                                                 status->Config->Outlet         = UNKNOWN_OUTLET;
       }

       ReconfigurePneu();


       if (( status->Position == 1 ) &&
           ( Inst_Config.Pneu.Column_1.Source == Inst_Config.Pneu.Column_2.Source ) &&
           ( Inst_Config.Pneu.Column_2.Defined == FALSE ))
       {
           LoadDefaultColumnSetpts( &Inst_Status.Pneu.Column_2 );
       }

       DisableRamp( (pRAMPINFO)status->Ramp_Info );
       SetRampSetptPointer( (pRAMPINFO)status->Ramp_Info, (INT32 *)&status->Ramp_Setpt.Head_Pressure );
       SetPressureRampDefault( status->Ramp_Info );
       SetRampInitValue( status->Ramp_Info, 689476/status->Ramp_Setpt.Ramp_Pres_Scaling );  /* 10 psi */
       SetRampPostValue( status->Ramp_Info, 689476/status->Ramp_Setpt.Ramp_Pres_Scaling );  /* 10 psi */
       if ( Inst_Config.Pneu.Frnt_Inlet.Type == VOLATILES )
       {
          SetRampInitTime( status->Ramp_Info, TimeToMilliSecs(250 ) ); /* 2.50 min */
       }
       if ( Inst_Config.Pneu.Back_Inlet.Type == VOLATILES )
       {
          SetRampInitTime( status->Ramp_Info, TimeToMilliSecs(250 ) ); /* 2.50 min */
       }
       EnableRamp(  (pRAMPINFO)status->Ramp_Info );

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

BIT8 ColumnSourceOrOutletChanged( pCOLUMN_STATUS status )

/**end_proto**/
{

   BIT8 result;

   switch ( status->Config->Source )
   {
      case FRNT_INLET:  result = TestForException ( FRNT_INLET_TYPE  )  ||
                                 TestForException ( FRNT_INLET_EPC   )  ||
                                 TestForException ( FRNT_INLET_RANGE );
                        break;

      case BACK_INLET:  result = TestForException ( BACK_INLET_TYPE  )  ||
                                 TestForException ( BACK_INLET_EPC   )  ||
                                 TestForException ( BACK_INLET_RANGE );
                        break;

      case AUX_3:       result = TestForException ( AUX_3_TYPE       )  ||
                                 TestForException ( AUX_3_RANGE      );
                        break;

      case AUX_4:       result = TestForException ( AUX_4_TYPE       )  ||
                                 TestForException ( AUX_4_RANGE      );
                        break;

      case AUX_5:       result = TestForException ( AUX_5_TYPE       )  ||
                                 TestForException ( AUX_5_RANGE      );
                        break;

      default:          result = FALSE;
   }

   if ( result ) return TRUE;  /* no sense in looking any farther */


   switch ( status->Config->Outlet )
   {
      case FRNT_DET:   result =  TestForException( FRNT_DET_TYPE_MISMATCH ) ||
                                 TestForException( FRNT_DET_EPC           ) ||
                                 TestForException( FRNT_DET_MUG_RANGE     );
                        break;

      case BACK_DET:   result =  TestForException( BACK_DET_TYPE_MISMATCH ) ||
                                 TestForException( BACK_DET_EPC           ) ||
                                 TestForException( BACK_DET_MUG_RANGE     );
                        break;

      default:         result = FALSE;
   }

   return result;

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void DefaultColumnIfHardwareChanged( pCOLUMN_STATUS status )

/**end_proto**/
{

    if ( ColumnSourceOrOutletChanged( status ) )
    {
         LoadDefaultColumnSetpts( status );
    }

}

/**begin_proto**/

void LoadDefaultDetSetpts( pDETECTOR_STATUS status )

/**end_proto**/
{

    switch ( status->Config->Type )
    {
        case EPC_FID: LoadDefaultFIDSetpts( status );
                      break;
        case EPC_TCD: LoadDefaultTCDSetpts( status );
                      break;
        case EPC_ECD: LoadDefaultECDSetpts( status );
                      break;
        case EPC_NPD: LoadDefaultNPDSetpts( status );
                      break;
        case EPC_FPD: LoadDefaultFPDSetpts( status );
                      break;
        case EPC_uECD:
        case EPC_uECD2:
                      LoadDefaultUECDSetpts( status );
                      break;
        case EPC_LDID: LoadDefaultLDIDSetpts( status );
                      break;
        case EPC_OEM: LoadDefaultAuxDetSetpts( status );
                      break;
        default:      LoadDefaultManDetSetpts( status );
    }

}

/**begin_proto**/

void LoadDefaultAuxSetpts( pAUX_STATUS status )

/**end_proto**/
{

        pAUX_CONFIG config;
        pAUX_WKFILE wkfile;

        config = status->Config;
        wkfile = status->Wkfile;

        config->Gas_Type = He;
        status->Wkfile->Pres_Equib_Time       = TimeToMilliSecs( 10 );  /* 6 seconds */

        wkfile->On_Off = OFF;

        SetPressureRampDefault( (pRAMPINFO)status->Ramp_Info );

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void SetPneuDefaultSetpts(void)

/**end_proto**/
{
     LoadDefaultInletSetpts( &Inst_Status.Pneu.Frnt_Inlet );
     LoadDefaultInletSetpts( &Inst_Status.Pneu.Back_Inlet );

     LoadDefaultDetSetpts( &Inst_Status.Pneu.Frnt_Detector );
     LoadDefaultDetSetpts( &Inst_Status.Pneu.Back_Detector );

     LoadDefaultAuxSetpts( &Inst_Status.Pneu.Aux.Aux_3 );
     LoadDefaultAuxSetpts( &Inst_Status.Pneu.Aux.Aux_4 );
     LoadDefaultAuxSetpts( &Inst_Status.Pneu.Aux.Aux_5 );

     LoadDefaultColumnSetpts( &Inst_Status.Pneu.Column_1 );
     LoadDefaultColumnSetpts( &Inst_Status.Pneu.Column_2 );
}

/**begin_proto**/

INT32 yGetInletPsRange( void *status, INT32 unused )

/**end_proto**/
{
#define STATUS ( (pINLET_STATUS)status )

     (void) unused;

     if ( !EpcInlet( STATUS ) )  return (INT32)0;

     return GetInletPSensorRange( STATUS );

#undef STATUS
}

/**begin_proto**/

INT32 yGetDetPsRange( void *status, INT32 gas_num )

/**end_proto**/
{

#define STATUS ( (pDETECTOR_STATUS)status )


     if ( !EpcDetector( STATUS ) )  return (INT32)0;

     return GetDetPSensorRange( STATUS, gas_num );


#undef STATUS
}

/**begin_proto**/

INT32 yGetPneuAuxPsRange( void *status, INT32 unused )

/**end_proto**/
{

#define STATUS ( (pAUX_STATUS)status )

     (void)unused;

     if ( !PneuAuxPresent( ) )  return (INT32)0;

     return GetAuxPSensorRange( STATUS );


#undef STATUS
}


INT32 yEpcPresent(void *item_id, INT32 item_qualifier)
{
    (void)item_id;
    (void)item_qualifier;
    return (INT32)!IamAdirtball();
}


INT32 yGetInletBaseType(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)GetInletType ( item_id );
}


INT32 yEpcInlet(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)EpcInlet ( item_id );
}


INT32 yGetInletGasType(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)GetInletGasType ( item_id );
}

UI_ERR ySetInletGasType(void *item_id, INT32 item_qualifier, INT32 item_value)
{
    (void)item_qualifier;

   if ( ((pINLET_STATUS)item_id)->Position == FRNT_INLET )
   {
       if ( TestForException ( FRNT_INLET_TYPE  ) ||
            TestForException ( FRNT_INLET_EPC   ) ||
            TestForException ( FRNT_INLET_RANGE ))
       {
           /* hardware configuration mismatch */
           return NOT_ALLOWED;
       }
   }
   else
   {
       if ( TestForException ( BACK_INLET_TYPE  ) ||
            TestForException ( BACK_INLET_EPC   ) ||
            TestForException ( BACK_INLET_RANGE ))
       {
           /* hardware configuration mismatch */
           return NOT_ALLOWED;
       }
   }

   return (UI_ERR)SetInletGasType ( (GAS_TYPE)item_value, item_id );
}


INT32 yGetInletPresEquibTime(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)GetInletPresEquibTime ( item_id );
}

UI_ERR ySetInletPresEquibTime(void *item_id, INT32 item_qualifier, INT32 item_value)
{
    (void)item_qualifier;

   if ( ((pINLET_STATUS)item_id)->Position == FRNT_INLET )
   {
       if ( TestForException ( FRNT_INLET_TYPE  ) ||
            TestForException ( FRNT_INLET_EPC   ) ||
            TestForException ( FRNT_INLET_RANGE ))
       {
           /* hardware configuration mismatch */
           return NOT_ALLOWED;
       }
   }
   else
   {
       if ( TestForException ( BACK_INLET_TYPE  ) ||
            TestForException ( BACK_INLET_EPC   ) ||
            TestForException ( BACK_INLET_RANGE ))
       {
           /* hardware configuration mismatch */
           return NOT_ALLOWED;
       }
   }

   return (UI_ERR)SetInletPresEquibTime ( item_value, item_id );
}

INT32 yGetInletFlowEquibTime(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)GetInletFlowEquibTime ( item_id );
}


UI_ERR ySetInletFlowEquibTime(void *item_id, INT32 item_qualifier, INT32 item_value)
{
    (void)item_qualifier;

   if ( ((pINLET_STATUS)item_id)->Position == FRNT_INLET )
   {
       if ( TestForException ( FRNT_INLET_TYPE  ) ||
            TestForException ( FRNT_INLET_EPC   ) ||
            TestForException ( FRNT_INLET_RANGE ))
       {
           /* hardware configuration mismatch */
           return NOT_ALLOWED;
       }
   }
   else
   {
       if ( TestForException ( BACK_INLET_TYPE  ) ||
            TestForException ( BACK_INLET_EPC   ) ||
            TestForException ( BACK_INLET_RANGE ))
       {
           /* hardware configuration mismatch */
           return NOT_ALLOWED;
       }
   }

   return (UI_ERR)SetInletFlowEquibTime ( item_value, item_id );
}

INT32 yGetInletVentState(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return ((INT32)GetVISplitPort ( item_id ) & 1 ); /* 2=plumbed -> rtn 0 */
                                                     /* 1=capped  -> rtn 1 */
}

#if 0
UI_ERR ySetInletVentState(void *item_id, INT32 item_qualifier, INT32 item_value)
{
    (void)item_qualifier;

   if ( ((pINLET_STATUS)item_id)->Position == FRNT_INLET )
   {
       if ( TestForException ( FRNT_INLET_TYPE  ) ||
            TestForException ( FRNT_INLET_EPC   ) ||
            TestForException ( FRNT_INLET_RANGE ))
       {
           /* hardware configuration mismatch */
           return NOT_ALLOWED;
       }
   }
   else
   {
       if ( TestForException ( BACK_INLET_TYPE  ) ||
            TestForException ( BACK_INLET_EPC   ) ||
            TestForException ( BACK_INLET_RANGE ))
       {
           /* hardware configuration mismatch */
           return NOT_ALLOWED;
       }
   }
    if (item_value==0) item_value = 2 ;
    return (UI_ERR)SetVISplitPort ( item_id, (PNEU_PORT_STATE)item_value );
}
#endif


INT32 yEpcDetector(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)EpcDetector ( item_id );
}


INT32 yGetDetectorGasType(void *item_id, INT32 item_qualifier)
{
    return (INT32)GetDetectorGasType ( item_id, item_qualifier );
}


UI_ERR ySetDetectorGasType(void *item_id, INT32 item_qualifier, INT32 item_value )
{
          if ( ((pDETECTOR_STATUS)item_id)->Position == FRNT_DET )
          {
               if ( TestForException ( FRNT_DET_EPC        ) ||
                    TestForException ( FRNT_DET_FUEL_RANGE ) ||
                    TestForException ( FRNT_DET_UTIL_RANGE ) ||
                    TestForException ( FRNT_DET_MUG_RANGE  ))
               {
                    return NOT_ALLOWED;
               }
          }
          else
          {
               if ( TestForException ( BACK_DET_EPC        ) ||
                    TestForException ( BACK_DET_FUEL_RANGE ) ||
                    TestForException ( BACK_DET_UTIL_RANGE ) ||
                    TestForException ( BACK_DET_MUG_RANGE  ))
               {
                    return NOT_ALLOWED;
               }
          }

    return (UI_ERR)SetDetectorGasType ( item_id, item_qualifier, (GAS_TYPE)item_value );
}


INT32 yPneuAuxPresent(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    (void)item_id;
    return (INT32)PneuAuxPresent ( );
}


INT32 yGetAuxGasType(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)GetAuxGasType ( item_id );
}

UI_ERR ySetAuxGasType(void *item_id, INT32 item_qualifier, INT32 item_value)
{
    (void)item_qualifier;

    switch (  ((pAUX_STATUS)item_id)->Position )
    {
      case AUX_3: if ( TestForException ( AUX_3_TYPE  )  ||
                       TestForException ( AUX_3_RANGE ))
                  {
                       return NOT_ALLOWED;
                  }
                  break;
      case AUX_4: if ( TestForException ( AUX_4_TYPE  )  ||
                       TestForException ( AUX_4_RANGE ))
                  {
                       return NOT_ALLOWED;
                  }
                  break;
      case AUX_5: if ( TestForException ( AUX_5_TYPE  )  ||
                       TestForException ( AUX_5_RANGE ))
                  {
                       return NOT_ALLOWED;
                  }
                  break;
    }


    return (UI_ERR)SetAuxGasType ( (GAS_TYPE)item_value, item_id );
}


INT32 yGetAuxPresEquibTime(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)GetAuxPresEquibTime ( item_id );
}

UI_ERR ySetAuxPresEquibTime(void *item_id, INT32 item_qualifier, INT32 item_value)
{
    (void)item_qualifier;

    switch (  ((pAUX_STATUS)item_id)->Position )
    {
      case AUX_3: if ( TestForException ( AUX_3_TYPE  )  ||
                       TestForException ( AUX_3_RANGE ))
                  {
                       return NOT_ALLOWED;
                  }
                  break;
      case AUX_4: if ( TestForException ( AUX_4_TYPE  )  ||
                       TestForException ( AUX_4_RANGE ))
                  {
                       return NOT_ALLOWED;
                  }
                  break;
      case AUX_5: if ( TestForException ( AUX_5_TYPE  )  ||
                       TestForException ( AUX_5_RANGE ))
                  {
                       return NOT_ALLOWED;
                  }
                  break;
    }


    return (UI_ERR)SetAuxPresEquibTime ( item_value, item_id );
}


INT32 yGetColumnLength(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)GetColumnLength ( item_id );
}


INT32 yGetColumnDiam(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)GetColumnDiam ( item_id );
}


INT32 yGetColumnFilmThickness(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)GetColumnFilmThickness ( item_id );
}


INT32 yGetColumnSource(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)GetColumnSource ( item_id );
}


INT32 yGetColumnOutlet(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)GetColumnOutlet ( item_id );
}


INT32 yGetColumnVacuumComp(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)GetColumnVacuumComp ( item_id );
}


INT32 yGetOutletPresComp(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)ColumnOutletPresCompEnabled ( item_id );
}


INT32 yGetOutletPresCompSetpt(void *item_id, INT32 item_qualifier)
{
    (void)item_qualifier;
    return (INT32)DcGetColumnOutletPresCompSetpt ( item_id );
}

/*************************************************************/

UI_ERR ySetColumnLength(void *item_id, INT32 item_qualifier, INT32 item_value )
{
    (void)item_qualifier;
    return (UI_ERR)SetColumnLength ( item_value, item_id );
}


UI_ERR ySetColumnDiam(void *item_id, INT32 item_qualifier, INT32 item_value )
{
    (void)item_qualifier;
    return (UI_ERR)SetColumnDiam ( item_value, item_id );
}


UI_ERR ySetColumnFilmThickness(void *item_id, INT32 item_qualifier, INT32 item_value )
{
    (void)item_qualifier;
    return (UI_ERR)SetColumnFilmThickness ( item_value, item_id );
}


UI_ERR ySetColumnSource(void *item_id, INT32 item_qualifier, INT32 item_value )
{
    (void)item_qualifier;
    return (UI_ERR)SetColumnSource ( (SOURCE_CONNECTION)item_value, item_id );
}


UI_ERR ySetColumnOutlet(void *item_id, INT32 item_qualifier, INT32 item_value )
{
    (void)item_qualifier;
    return (UI_ERR)SetColumnOutlet ( (OUTLET_CONNECTION)item_value, item_id );
}


UI_ERR ySetColumnVacuumComp(void *item_id, INT32 item_qualifier, INT32 item_value )
{
    (void)item_qualifier;
    return (UI_ERR)SetColumnVacuumComp ( (ON_OFF)item_value, item_id );
}


UI_ERR ySetOutletPresComp(void *item_id, INT32 item_qualifier, INT32 item_value )
{
    (void)item_qualifier;
    return (UI_ERR)SetColumnOutletPresComp( (ON_OFF)item_value, item_id );
}


UI_ERR ySetOutletPresCompSetpt(void *item_id, INT32 item_qualifier, INT32 item_value )
{
    (void)item_qualifier;
    return (UI_ERR)DcSetColumnOutletPresCompSetpt ( item_value, item_id );
}

UI_ERR yReconfigurePneu(void *item_id, INT32 item_qualifier, INT32 item_value )
{
    (void) item_id;
    (void) item_qualifier;
    (void) item_value;

    ReconfigurePneu();

    return OK;
}






typedef INT32  (* const pGET_FUNC)(void *item_id, U_INT32 item_qualifier);
typedef UI_ERR (* const pSET_FUNC)(void *item_id, U_INT32 item_qualifier, INT32 item_value );
typedef enum { INSTALL, CHECK, JUMP } ETYPE;

typedef struct
        {
            ETYPE    entry_type;
            void    *item;
            U_INT16  item_size;
            void    *func;
            void    *id;
            INT32    qual;
            EXCEPTION  exception;
        } METH_CHECK;

#define A_AN_S(x) (void *)&x, (U_INT16)sizeof(x)

#define pANY  void *)(U_INT32

static const METH_CHECK Method_Check_Table[] = {


 { CHECK,   A_AN_S(gccw.EpcBdPresence              ), (pANY)yEpcPresent,               0,   0,  DIRTBALL                },


       /*  *  *  *  *  *  *  *   F R O N T   I N L E T   *  *  *  *  *  */

       /* hardware config */

 { CHECK,   A_AN_S(gccw.InletVentState          [0]), (pANY)yGetInletVentState,      pFINLT, 0, FRNT_INLET_VENT_STATE   },
 { JUMP,    A_AN_S(gccw.InletVentState          [0]), (pANY)yGetInletVentState,      pFINLT, 0, (EXCEPTION)5            },
 { CHECK,   A_AN_S(gccw.InletType               [0]), (pANY)yGetInletBaseType,       pFINLT, 0, FRNT_INLET_TYPE         },
 { JUMP,    A_AN_S(gccw.InletType               [0]), (pANY)yGetInletBaseType,       pFINLT, 0, (EXCEPTION)3            },
 { CHECK,   A_AN_S(gccw.IsInletEpc              [0]), (pANY)yEpcInlet,               pFINLT, 0, FRNT_INLET_EPC          },
 { JUMP,    A_AN_S(gccw.IsInletEpc              [0]), (pANY)yEpcInlet,               pFINLT, 0, (EXCEPTION)1            },
 { CHECK,   A_AN_S(gccw.InletPSensorRange       [0]), (pANY)yGetInletPsRange,        pFINLT, 0, FRNT_INLET_RANGE        },

       /* user     config */

 { CHECK,   A_AN_S(gccw.InletPresEquib          [0]), (pANY)yGetInletPresEquibTime,  pFINLT, 0, FRNT_INLET_PRES_EQUIB   },
 { INSTALL, A_AN_S(gccw.InletPresEquib          [0]), (pANY)ySetInletPresEquibTime,  pFINLT, 0, (EXCEPTION)0            },
 { CHECK,   A_AN_S(gccw.InletFlowEquib          [0]), (pANY)yGetInletFlowEquibTime,  pFINLT, 0, FRNT_INLET_FLOW_EQUIB   },
 { INSTALL, A_AN_S(gccw.InletFlowEquib          [0]), (pANY)ySetInletFlowEquibTime,  pFINLT, 0, (EXCEPTION)0            },
 { CHECK,   A_AN_S(gccw.InletGasType            [0]), (pANY)yGetInletGasType,        pFINLT, 0, FRNT_INLET_GAS_TYPE     },
 { INSTALL, A_AN_S(gccw.InletGasType            [0]), (pANY)ySetInletGasType,        pFINLT, 0, (EXCEPTION)0            },


       /*  *  *  *  *  *  *  *     B A C K   I N L E T   *  *  *  *  *  */

       /* hardware config */

 { CHECK,   A_AN_S(gccw.InletVentState          [1]), (pANY)yGetInletVentState,      pBINLT, 0, BACK_INLET_VENT_STATE   },
 { JUMP,    A_AN_S(gccw.InletVentState          [1]), (pANY)yGetInletVentState,      pBINLT, 0, (EXCEPTION)5            },
 { CHECK,   A_AN_S(gccw.InletType               [1]), (pANY)yGetInletBaseType,       pBINLT, 0, BACK_INLET_TYPE         },
 { JUMP,    A_AN_S(gccw.InletType               [1]), (pANY)yGetInletBaseType,       pBINLT, 0, (EXCEPTION) 3           },
 { CHECK,   A_AN_S(gccw.IsInletEpc              [1]), (pANY)yEpcInlet,               pBINLT, 0, BACK_INLET_EPC          },
 { JUMP,    A_AN_S(gccw.IsInletEpc              [1]), (pANY)yEpcInlet,               pBINLT, 0, (EXCEPTION) 1           },
 { CHECK,   A_AN_S(gccw.InletPSensorRange       [1]), (pANY)yGetInletPsRange,        pBINLT, 0, BACK_INLET_RANGE        },

       /* user     config */

 { CHECK,   A_AN_S(gccw.InletPresEquib          [1]), (pANY)yGetInletPresEquibTime,  pBINLT, 0, BACK_INLET_PRES_EQUIB   },
 { INSTALL, A_AN_S(gccw.InletPresEquib          [1]), (pANY)ySetInletPresEquibTime,  pBINLT, 0, (EXCEPTION) 0           },
 { CHECK,   A_AN_S(gccw.InletFlowEquib          [1]), (pANY)yGetInletFlowEquibTime,  pBINLT, 0, BACK_INLET_FLOW_EQUIB   },
 { INSTALL, A_AN_S(gccw.InletFlowEquib          [1]), (pANY)ySetInletFlowEquibTime,  pBINLT, 0, (EXCEPTION) 0           },
 { CHECK,   A_AN_S(gccw.InletGasType            [1]), (pANY)yGetInletGasType,        pBINLT, 0, BACK_INLET_GAS_TYPE     },
 { INSTALL, A_AN_S(gccw.InletGasType            [1]), (pANY)ySetInletGasType,        pBINLT, 0, (EXCEPTION) 0           },


       /*  *  *  *  *  *  *  *   F R O N T   D E T E C T O R   *  *  *  *  *  */

       /* hardware config */

        /* revisit: add call to check det type here */
 { CHECK,   A_AN_S(gccw.IsDetectorEpc           [0]), (pANY)yEpcDetector,            pFDET,  0,  FRNT_DET_EPC            },
 { JUMP,    A_AN_S(gccw.IsDetectorEpc           [0]), (pANY)yEpcDetector,            pFDET,  0,  (EXCEPTION) 3           },
 { CHECK,   A_AN_S(gccw.DetFuelSensorRange      [0]), (pANY)yGetDetPsRange,          pFDET,  1,  FRNT_DET_FUEL_RANGE     },
 { CHECK,   A_AN_S(gccw.DetUtilSensorRange      [0]), (pANY)yGetDetPsRange,          pFDET,  2,  FRNT_DET_UTIL_RANGE     },
 { CHECK,   A_AN_S(gccw.DetMugSensorRange       [0]), (pANY)yGetDetPsRange,          pFDET,  3,  FRNT_DET_MUG_RANGE      },

       /* user     config */

 { CHECK,   A_AN_S(gccw.DetUtilGasType          [0]), (pANY)yGetDetectorGasType,     pFDET,  2,  FRNT_DET_UTIL_GAS_TYPE  },
 { INSTALL, A_AN_S(gccw.DetUtilGasType          [0]), (pANY)ySetDetectorGasType,     pFDET,  2,  (EXCEPTION) 0           },
 { CHECK,   A_AN_S(gccw.DetMugGasType           [0]), (pANY)yGetDetectorGasType,     pFDET,  3,  FRNT_DET_MUG_GAS_TYPE   },
 { INSTALL, A_AN_S(gccw.DetMugGasType           [0]), (pANY)ySetDetectorGasType,     pFDET,  3,  (EXCEPTION) 0           },



       /*  *  *  *  *  *  *  *    B A C K    D E T E C T O R   *  *  *  *  *  */

       /* hardware config */

        /* revisit: add call to check det type here */
 { CHECK,   A_AN_S(gccw.IsDetectorEpc           [1]), (pANY)yEpcDetector,            pBDET,  0,  BACK_DET_EPC            },
 { JUMP,    A_AN_S(gccw.IsDetectorEpc           [1]), (pANY)yEpcDetector,            pBDET,  0,  (EXCEPTION) 3           },
 { CHECK,   A_AN_S(gccw.DetFuelSensorRange      [1]), (pANY)yGetDetPsRange,          pBDET,  1,  BACK_DET_FUEL_RANGE     },
 { CHECK,   A_AN_S(gccw.DetUtilSensorRange      [1]), (pANY)yGetDetPsRange,          pBDET,  2,  BACK_DET_UTIL_RANGE     },
 { CHECK,   A_AN_S(gccw.DetMugSensorRange       [1]), (pANY)yGetDetPsRange,          pBDET,  3,  BACK_DET_MUG_RANGE      },

       /* user     config */

 { CHECK,   A_AN_S(gccw.DetUtilGasType          [1]), (pANY)yGetDetectorGasType,     pBDET,  2,  BACK_DET_UTIL_GAS_TYPE  },
 { INSTALL, A_AN_S(gccw.DetUtilGasType          [1]), (pANY)ySetDetectorGasType,     pBDET,  2,  (EXCEPTION) 0           },
 { CHECK,   A_AN_S(gccw.DetMugGasType           [1]), (pANY)yGetDetectorGasType,     pBDET,  3,  BACK_DET_MUG_GAS_TYPE   },
 { INSTALL, A_AN_S(gccw.DetMugGasType           [1]), (pANY)ySetDetectorGasType,     pBDET,  3,  (EXCEPTION) 0           },



       /*  *  *  *  *  *  *  *    P N E U    A U X   3   *  *  *  *  *  *  *  */

       /* hardware config */

 { CHECK,   A_AN_S(gccw.PneuAuxType             [0]), (pANY)yPneuAuxPresent,         pA3,    0, AUX_3_TYPE              },
 { JUMP,    A_AN_S(gccw.PneuAuxType             [0]), (pANY)yPneuAuxPresent,         pA3,    0, (EXCEPTION) 1           },
 { CHECK,   A_AN_S(gccw.AuxPSensorRange         [0]), (pANY)yGetPneuAuxPsRange,      pA3,    0, AUX_3_RANGE             },

       /* user     config */

 { CHECK,   A_AN_S(gccw.AuxPresEquibTime        [0]), (pANY)yGetAuxPresEquibTime,    pA3,    0, AUX_3_PRES_EQUIB        },
 { INSTALL, A_AN_S(gccw.AuxPresEquibTime        [0]), (pANY)ySetAuxPresEquibTime,    pA3,    0, (EXCEPTION) 0           },
 { CHECK,   A_AN_S(gccw.AuxGasType              [0]), (pANY)yGetAuxGasType,          pA3,    0, AUX_3_GAS_TYPE          },
 { INSTALL, A_AN_S(gccw.AuxGasType              [0]), (pANY)ySetAuxGasType,          pA3,    0, (EXCEPTION) 0           },



       /*  *  *  *  *  *  *  *    P N E U    A U X   4   *  *  *  *  *  *  *  */

       /* hardware config */

 { CHECK,   A_AN_S(gccw.PneuAuxType             [1]), (pANY)yPneuAuxPresent,         pA4,    0, AUX_4_TYPE              },
 { JUMP,    A_AN_S(gccw.PneuAuxType             [1]), (pANY)yPneuAuxPresent,         pA4,    0, (EXCEPTION) 1           },
 { CHECK,   A_AN_S(gccw.AuxPSensorRange         [1]), (pANY)yGetPneuAuxPsRange,      pA4,    0, AUX_4_RANGE             },

       /* user     config */

 { CHECK,   A_AN_S(gccw.AuxPresEquibTime        [1]), (pANY)yGetAuxPresEquibTime,    pA4,    0, AUX_4_PRES_EQUIB        },
 { INSTALL, A_AN_S(gccw.AuxPresEquibTime        [1]), (pANY)ySetAuxPresEquibTime,    pA4,    0, (EXCEPTION) 0           },
 { CHECK,   A_AN_S(gccw.AuxGasType              [1]), (pANY)yGetAuxGasType,          pA4,    0, AUX_4_GAS_TYPE          },
 { INSTALL, A_AN_S(gccw.AuxGasType              [1]), (pANY)ySetAuxGasType,          pA4,    0, (EXCEPTION) 0           },



       /*  *  *  *  *  *  *  *    P N E U    A U X   5   *  *  *  *  *  *  *  */

       /* hardware config */

 { CHECK,   A_AN_S(gccw.PneuAuxType             [2]), (pANY)yPneuAuxPresent,         pA5,    0, AUX_5_TYPE              },
 { JUMP,    A_AN_S(gccw.PneuAuxType             [2]), (pANY)yPneuAuxPresent,         pA5,    0, (EXCEPTION) 1                       },
 { CHECK,   A_AN_S(gccw.AuxPSensorRange         [2]), (pANY)yGetPneuAuxPsRange,      pA5,    0, AUX_5_RANGE             },

       /* user     config */

 { CHECK,   A_AN_S(gccw.AuxPresEquibTime        [2]), (pANY)yGetAuxPresEquibTime,    pA5,    0, AUX_5_PRES_EQUIB        },
 { INSTALL, A_AN_S(gccw.AuxPresEquibTime        [2]), (pANY)ySetAuxPresEquibTime,    pA5,    0, (EXCEPTION) 0           },
 { CHECK,   A_AN_S(gccw.AuxGasType              [2]), (pANY)yGetAuxGasType,          pA5,    0, AUX_5_GAS_TYPE          },
 { INSTALL, A_AN_S(gccw.AuxGasType              [2]), (pANY)ySetAuxGasType,          pA5,    0, (EXCEPTION) 0           },



       /*  *  *  *  *  *  *  *    C O L U M N   1  *  *  *  *  *  *  *  *  *  */

       /* user     config */

 { CHECK,   A_AN_S(gccw.ColLength               [0]), (pANY)yGetColumnLength,        pCOL1,  0, COLUMN1_LENGTH          },
 { CHECK,   A_AN_S(gccw.ColDiam                 [0]), (pANY)yGetColumnDiam,          pCOL1,  0, COLUMN1_DIAM            },
 { CHECK,   A_AN_S(gccw.ColFilmThick            [0]), (pANY)yGetColumnFilmThickness, pCOL1,  0, COLUMN1_FILM_THICK      },
 { CHECK,   A_AN_S(gccw.ColSource               [0]), (pANY)yGetColumnSource,        pCOL1,  0, COLUMN1_SOURCE          },
 { CHECK,   A_AN_S(gccw.ColOutlet               [0]), (pANY)yGetColumnOutlet,        pCOL1,  0, COLUMN1_OUTLET          },
 { CHECK,   A_AN_S(gccw.ColVacuumComp           [0]), (pANY)yGetColumnVacuumComp,    pCOL1,  0, COLUMN1_VACUUM_COMP     },
 { CHECK,   A_AN_S(gccw.ColOutletPresCompSetpt  [0]), (pANY)yGetOutletPresCompSetpt, pCOL1,  0, COLUMN1_PRES_COMP_SETPT },
 { CHECK,   A_AN_S(gccw.ColOutletPresCompEnabled[0]), (pANY)yGetOutletPresComp,      pCOL1,  0, COLUMN1_OUTLET_PRES_COMP},

 { INSTALL, A_AN_S(gccw.ColLength               [0]), (pANY)ySetColumnLength,        pCOL1,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColDiam                 [0]), (pANY)ySetColumnDiam,          pCOL1,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColFilmThick            [0]), (pANY)ySetColumnFilmThickness, pCOL1,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColSource               [0]), (pANY)ySetColumnSource,        pCOL1,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColOutlet               [0]), (pANY)ySetColumnOutlet,        pCOL1,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColVacuumComp           [0]), (pANY)ySetColumnVacuumComp,    pCOL1,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColOutletPresCompSetpt  [0]), (pANY)ySetOutletPresCompSetpt, pCOL1,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColOutletPresCompEnabled[0]), (pANY)ySetOutletPresComp,      pCOL1,  0, (EXCEPTION) 0           },



       /*  *  *  *  *  *  *  *    C O L U M N   2  *  *  *  *  *  *  *  *  *  */

       /* user     config */

 { CHECK,   A_AN_S(gccw.ColLength               [1]), (pANY)yGetColumnLength,        pCOL2,  0, COLUMN2_LENGTH          },
 { CHECK,   A_AN_S(gccw.ColDiam                 [1]), (pANY)yGetColumnDiam,          pCOL2,  0, COLUMN2_DIAM            },
 { CHECK,   A_AN_S(gccw.ColFilmThick            [1]), (pANY)yGetColumnFilmThickness, pCOL2,  0, COLUMN2_FILM_THICK      },
 { CHECK,   A_AN_S(gccw.ColSource               [1]), (pANY)yGetColumnSource,        pCOL2,  0, COLUMN2_SOURCE          },
 { CHECK,   A_AN_S(gccw.ColOutlet               [1]), (pANY)yGetColumnOutlet,        pCOL2,  0, COLUMN2_OUTLET          },
 { CHECK,   A_AN_S(gccw.ColVacuumComp           [1]), (pANY)yGetColumnVacuumComp,    pCOL2,  0, COLUMN2_VACUUM_COMP     },
 { CHECK,   A_AN_S(gccw.ColOutletPresCompSetpt  [1]), (pANY)yGetOutletPresCompSetpt, pCOL2,  0, COLUMN2_PRES_COMP_SETPT },
 { CHECK,   A_AN_S(gccw.ColOutletPresCompEnabled[1]), (pANY)yGetOutletPresComp,      pCOL2,  0, COLUMN2_OUTLET_PRES_COMP},

 { INSTALL, A_AN_S(gccw.ColLength               [1]), (pANY)ySetColumnLength,        pCOL2,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColDiam                 [1]), (pANY)ySetColumnDiam,          pCOL2,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColFilmThick            [1]), (pANY)ySetColumnFilmThickness, pCOL2,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColSource               [1]), (pANY)ySetColumnSource,        pCOL2,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColOutlet               [1]), (pANY)ySetColumnOutlet,        pCOL2,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColVacuumComp           [1]), (pANY)ySetColumnVacuumComp,    pCOL2,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColOutletPresCompSetpt  [1]), (pANY)ySetOutletPresCompSetpt, pCOL2,  0, (EXCEPTION) 0           },
 { INSTALL, A_AN_S(gccw.ColOutletPresCompEnabled[1]), (pANY)ySetOutletPresComp,      pCOL2,  0, (EXCEPTION) 0           },



       /*  *  *  *  *  *  *  *    R E C O N F I G U R E  *  *  *  *  *  *  *  */


 { INSTALL, A_AN_S(gccw.EpcBdPresence),               (pANY)yReconfigurePneu,            0,  0, (EXCEPTION) 0           },

};



/**begin_proto**/

void CheckPneuConfigInWkfile ( void )

/**end_proto**/
{

    METH_CHECK *p;
    BIT8        result;
    U_INT32     method_value;
    U_INT32     current_value;
    U_INT32     i;

    meth_check_errors = 0;

    for ( i = 0 ; i < sizeof( Method_Check_Table ) / sizeof( METH_CHECK ) ; i ++ )
    {
       p = (METH_CHECK *)&Method_Check_Table[ i ];

       if ( p->entry_type == INSTALL ) continue;

       switch ( p->item_size )
       {
       case 1: method_value  = (INT32) *(INT8 *)(p->item);
               current_value = (INT32) ((pGET_FUNC)(U_INT32)p->func) ( p->id, p->qual );
               break;
       case 2: method_value  = (INT32) *(INT16 *)(p->item);
               current_value = (INT32) ((pGET_FUNC)(U_INT32)p->func) ( p->id, p->qual );
               break;
       case 4: method_value  = (INT32) *(INT32 *)(p->item);
               current_value = (INT32) ((pGET_FUNC)(U_INT32)p->func) ( p->id, p->qual );
               break;
       default: method_value  =  0xffff;
                current_value =  0;
       }

       result = method_value == current_value;

       if ( p->entry_type == CHECK )
       {
          if ( result == FALSE )
          {
              SetException( p->exception );
              meth_error_list[ meth_check_errors ].item    = (U_INT16)p->exception;
              meth_error_list[ meth_check_errors ].current = current_value;
              meth_error_list[ meth_check_errors ].method  = method_value;
              meth_check_errors++;
          }
       }
       else if ( p->entry_type == JUMP )
       {
          if ( result == FALSE ) i += (U_INT16)p->exception; /* the skip count */
       }
    }

}


/**begin_proto**/

void SavePneuConfigInWkfile ( void )

/**end_proto**/
{

    METH_CHECK *p;
    U_INT32     i;

    for ( i = 0 ; i < sizeof( Method_Check_Table ) / sizeof( METH_CHECK ) ; i ++ )
    {
       p = (METH_CHECK *)&Method_Check_Table[ i ];

       if ( p->entry_type == JUMP    ) continue;
       if ( p->entry_type == INSTALL ) continue;

       switch ( p->item_size )
       {
       case 1: *(INT8  *)(p->item) = (INT8 )((pGET_FUNC)(U_INT32)p->func)( p->id, p->qual );
               break;
       case 2: *(INT16 *)(p->item) = (INT16)((pGET_FUNC)(U_INT32)p->func)( p->id, p->qual );
               break;
       case 4: *(INT32 *)(p->item) = (INT32)((pGET_FUNC)(U_INT32)p->func)( p->id, p->qual );
               break;
       }
    }

}



/**begin_proto**/

void InstallPneuConfigInWkfile ( void )

/**end_proto**/
{

    METH_CHECK *p;
    U_INT32     i;

    for ( i = 0 ; i < sizeof( Method_Check_Table ) / sizeof( METH_CHECK ) ; i ++ )
    {
       p = (METH_CHECK *)&Method_Check_Table[ i ];

       if ( p->entry_type != INSTALL ) continue;

       switch ( p->item_size )
       {
       case 1: (void) ((pSET_FUNC)(U_INT32)p->func)( p->id, p->qual, (INT32)( *(INT8 *)p->item) );
               break;
       case 2: (void) ((pSET_FUNC)(U_INT32)p->func)( p->id, p->qual, (INT32)( *(INT16 *)p->item) );
               break;
       case 4: (void) ((pSET_FUNC)(U_INT32)p->func)( p->id, p->qual, (INT32)( *(INT32 *)p->item) );
               break;
       }

    }

}



/***********************************************************************/
/* FUNCTION: CheckCPFInletConfigInWkfile                               */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:  This functions checks the method configuration against    */
/*         the actual configuration and issues an exception for a      */
/*         mismatch.                                                   */
/*                                                                     */
/* RETURNED VALUE:  None.                                              */
/*                                                                     */
/***********************************************************************/

/**begin_proto**/

void CheckCPFInletConfigInWkfile(void)

/**end_proto**/
{
POSITION pos;

   /* check for inlet title mismatch */
   for (pos = (POSITION)0; pos < (POSITION)2; pos++)
   {
      if(GetCPFInletTitlePresence(pos) != gccw.CPFInletTitlePresence[pos])
      {
            /* set exception */
            SetNewException((pos == FRONT) ? F_CPF_INL_TITLE_MISMATCH :
                                     B_CPF_INL_TITLE_MISMATCH, 0, 0);
      }
      if(GetCPFInletTitlePresence(pos) == TRUE)
      {
         if( (StrLen(GetCPFInletTitle(pos))!=StrLen(gccw.CPFInletTitle[pos])) ||
                (StrNCmp(GetCPFInletTitle(pos), gccw.CPFInletTitle[pos],
                   StrLen(gccw.CPFInletTitle[pos])) != 1) )
         {
               /* set exception */
              SetNewException((pos == FRONT) ? F_CPF_INL_TITLE_MISMATCH :
                                     B_CPF_INL_TITLE_MISMATCH, 0, 0);
         }
      }
   }
}

